<!DOCTYPE html>
<html>
<head>
<div th:include="base-libs :: base-libs" />
<title>综合月报</title>


<meta name="content-type" content="text/html; charset=UTF-8">
	<style>
		body {
			background: #fff;
			overflow:scroll;
			text-align: center;
		}
		.laydate-icon{
		    line-height: 28px;
		    background-color: #fff;
		    height: 28px;
		    border: 1px solid #B6B6B6;
		    border-radius: 5px;
		    width:84% !important;
		}
		.titleTd{
			width:21%;
		}
	</style>
	
	<script>
		$(function(){
			$(this).registerManagerPage({callback: initView});
			initData();
		})
		
		function initView(){
			
			$("body").on('click','#btnTj',function(){
				//预约方式处理
				getYyfs();
				var params = {
						type: $("#myForm").data("type"),
						YYFS: $("#YYFS").val(),
						ZT: 1,
				}
				
				
				if($(".form-control").QuickValidate()){
					$.QuickRemote.AjaxFiledFormSubmit("myForm", function(result){ 
						if(result.state){
							$.QuickAlert.alertNormal("月报保存成功！", {callback: function(){
//								btnController('remove');
								//$(".form-control").attr("disabled","disabled");
                                queryDataByNowDate();
//								$("#ZTMC").val("待审核");
							}});
						}else{
							var info = result["info"];
							$.QuickAlert.alertFail({content: info["faultInfo"]});
						}
					}, params)
				}
			})
			
			//审核记录
			$("body").on('click','#btnShjl',function(){
				StoreCache.setCache("BBID", $("#ID").val());
				parent.layer.open({
					  type: 2,
					  area: ["60%", "500px"],
					  content: contextRoot + 'wsj/bbShjl.html',
					  scrollbar: false,
					  resize: false,
					  title:'审核记录'
				});
			});
			
			//载入值域：Yyfs
			var yyfsArr = StoreCache.getCache('TB_ZY_YYFS');
			if(!$.isEmptyObject(yyfsArr)){
				var yyfsBox = $("#yyfsBox");
				var inputCss = "width:17px;display:inline-block;float:left";
				$.each(yyfsArr.data, function(i, item){
					var input = $("<input>").attr({style: inputCss, type: 'checkbox', name: 'YYFS_', value: item.XMDM});
					var div = $("<div>").css({'float':'left', 'margin-right': '8px'}).html(item.XMMC);
					yyfsBox.append(input,div)
				})
			}
			
		}
		
		function initData(){
			var date = new Date(),
				NF = date.getFullYear(),
				YF = date.getMonth() + 1;
			if(YF<10) YF = '0' + YF;
			queryDataByNowDate({NF: NF,YF: YF});
		}
		
		/** 通过当前时间查询数据  */
		function queryDataByNowDate(dateObj){
		    var config = $.extend({},dateObj);
			if(StringUtils.isEmpty(config.NF)){
                config = getYearAndMonth();
			}
			var queryParams = {
				NF: config.NF,
				YF: config.YF
			}
			var backParams = {
				NFYF: config.NF + '-' + config.YF
			}
			$.QuickRemote.AjaxJson(contextRoot + "zhyb/queryOne", queryDataByNowDateBack, queryParams, backParams);
		}
		/** 通过当前时间查询数据--回调  */
		function queryDataByNowDateBack(result, backParams){
			if(StringUtils.isEmpty(result.errInfo)){
				result = $.extend(result,backParams);
				if(result.ZT == 1 || result.ZT == 3){
					//待审核||审核通过
					btnController('remove');
					$("input:not('#NFYF')").attr("disabled",'disabled');
				}else if(result.ZT == 2){
					//审核不通过
					$("#myForm").data("type","update");
                    $("input:not('#NFYF')").removeAttr("disabled");
					btnController('add');
				}else{
					$("#myForm").data("type","add");
                    $("input:not('#NFYF')").removeAttr("disabled");
					btnController('add');
				}
				var shztObj = {'0':'暂存','1':'待审核','2':'审核不通过','3':'审核通过'};
				result.ZTMC = shztObj[result.ZT] || '未填报';
				$(".form-control").each(function(){
					var name = $(this).attr('name');
					$(this).val(result[name]).html(result[name]);
				})
				
				//选中预约方式
				setYyfs();
				
				//设置keyup事件，计算百分比
				var keyupParamArr = [
	                    ['ZYXZRC','ZYXZLYRC','ZYXZLYL'],//住院下转履约率
	                    ['ZRRC','ZRLYRC','ZRLYL'],//转入履约率
	                    ['MZZRRC','MZZRLYRC','MZZRLYL'],//门诊转入履约率
	                    ['ZYZRRC','ZYZRLYRC','ZYZRLYL']//住院转入履约率
	            ];
				setKeyupFun(keyupParamArr);
			}else{
				$.QuickAlert.alertFail({content: result.errInfo});
			}
		}
		
		/** 按钮控制  */
		function btnController(type){
			if(type == 'add'){
				var btns = $("#btnBox").html();
				$("#south").empty().append($(btns)).show();
			}else{
				$("#south").hide().empty();
			}
			$('body').layout("resize");
		}
		
		/** 预约方式字段处理 */
		function getYyfs(){
			var yyfsArr = [];
			$('input[name=YYFS_]:checked').each(function(){
				yyfsArr.push($(this).val());
			})
			$("#YYFS").val(yyfsArr.join());
		}
		
		/** 载入预约方式  */
		function setYyfs(){
			//清空选中
			$('input[name=YYFS_]').removeAttr("checked");
			
			var yyfsArr = $("#YYFS").val().split(',');
			$.each(yyfsArr, function(i,item){
				$('input[name=YYFS_]').each(function(){
					if($(this).val()==item){
						$(this).prop("checked","checked");
						return false;
					}
				})
			})
		}
		
		/**  获取选择的年份和月份  */
		function getYearAndMonth() {
		    var NF,YF;
			if(StringUtils.isEmpty($dp.cal)){
				var date = new Date();
				NF = date.getFullYear();
				YF = date.getMonth() + 1;
			}else{
				NF = $dp.cal.newdate.y;
				YF = $dp.cal.newdate.M;
			}
			if(YF<10) YF = '0' + YF;
			return {NF: NF,YF: YF};
		}
		
		/** 设置keyup事件  */
		function setKeyupFun(keyupParamArr){
			$.each(keyupParamArr, function(i,item){
				$('#'+item[0]).add('#'+item[1]).keyup(function(){
					percent(item[0], item[1], item[2], item[3], item[4]);
				})
				$('#'+item[0]).trigger('keyup');
			})
		}
		
		/** 
		 *	计算百分百： csId:除数id | bcsId:被除数id | replyId:展示结果的标签id | cs:除数 | bcs:被除数 
		 *		注：当csId与cs（bcsId与bcs）同时存在时，以cs(bcs)为主--也就是直接指定静态的除数（被除数）
		 */
		function percent(csId,bcsId,replyId,cs,bcs){
			var num1 = parseFloat(cs || $("#"+csId).val());
			var num2 = parseFloat(bcs || $("#"+bcsId).val());
			var result;
			if(num1 && num2){
				result = (num1/num2*100).toFixed(2) + "%";
			}
			$("#"+replyId).val(result).html(result);
		}
	</script>
</head>

<body class="easyui-layout">
<form id="myForm" action="save" >
	<div region="north" style="height:60px;border:0;border-bottom:1px solid #ddd">
		<table class="form-table">
			<tr>
				<td class="td-text">审核状态：</td>
				<td class="td-content">
					<input id="ZTMC" name="ZTMC" class="form-control" readonly="readonly"/>
				</td>
				<td class="td-text"><label>机构名称：</label></td>
				<td class="td-content">
					<input name="JGMC" class="form-control" readonly="readonly"/>
				</td>
				<td class="td-text"><label>月份：</label></td>
				<td class="td-content">
					<input id="NFYF" class="form-control laydate-icon" name="NFYF" onclick="WdatePicker({dateFmt:'yyyy-MM',onpicking:queryDataByNowDate})" 
						quick-config="label:'月份', validateProxy:'notNull'"/>
				</td>
				<td>
					<button id="btnShjl" class="btn btn-info" type="button">审核记录</button>
				</td>
			</tr>
		</table>
	</div>
	
	<div region="center" border="false" style="overflow-x:hidden;">
		<div class="easyui-panel" title="一、就诊及转诊情况" border="false" style="width:99.9%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.就诊人次：</label></td>
					<td class="td-content">
						<input id="ID" name="ID" class="form-control" type="hidden"/>
						<input name="JZRC" class="form-control" 
						quick-config="label:'就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.签约就诊人次：</label></td>
					<td class="td-content">
						<input name="QYJZRC" class="form-control" 
						quick-config="label:'签约就诊人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text" style="vertical-align:middle"><label>3.预约人次：</label></td>
					<td class="td-content" style="vertical-align:middle">
						<input name="YYRC" class="form-control" 
						quick-config="label:'预约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text" style="vertical-align:middle">
						<label>4.预约方式：</label>
						<input class="form-control"  name="YYFS" id="YYFS"  style="display:none" hidden="hidden"
						quick-config="label:'预约方式', validateProxy:'notNull'" cacheTable="TB_ZY_YYFS"/>
					</td>
					<td class="td-content" style="vertical-align:middle" id="yyfsBox">
				</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.住院下转人次</label>/住院下转履约人次：</td>
					<td class="td-content">
						<input id="ZYXZRC" name="ZYXZRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院下转人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZYXZLYRC" name="ZYXZLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院下转履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>6.住院下转履约率：</label></td>
					<td class="td-content">
						<input id="ZYXZLYL" class="form-control" placeholder="住院下转履约人次/住院下转人次" readonly/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>7.转入人次</label>/转入履约人次：</td>
					<td class="td-content">
						<input id="ZRRC" name="ZRRC" class="form-control" style="width:40%;" 
						quick-config="label:'转入人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZRLYRC" name="ZRLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'转入履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text">8.转入履约率：</td>
					<td class="td-content">
						<input id="ZRLYL" class="form-control" placeholder="转入履约人次/转入人次" readonly/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>9.门诊转入人次</label>/门诊转入履约人次：</td>
					<td class="td-content">
						<input id="MZZRRC" name="MZZRRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊转入人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="MZZRLYRC" name="MZZRLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'门诊转入履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>10.门诊转入履约率：</label></td>
					<td class="td-content">
						<input id="MZZRLYL" class="form-control" placeholder="门诊转入履约人次/门诊转入人次" readonly/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>11.住院转入人次</label>/住院转入履约人次：</td>
					<td class="td-content">
						<input id="ZYZRRC" name="ZYZRRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院转入人次', validateProxy:'notNull length num', length: '10'"/>
						
						<span style="display:inline-block;width:7.5%;text-align:center;">/</span>
						
						<input id="ZYZRLYRC" name="ZYZRLYRC" class="form-control" style="width:40%;" 
						quick-config="label:'住院转入履约人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text">12.住院转入履约率：</td>
					<td class="td-content">
						<input id="ZYZRLYL" class="form-control" placeholder="住院转入履约人次/住院转入人次" readonly/>
					</td>
				</tr>
			</table>
		</div>
		<div class="easyui-panel" title="二、医联体建设情况" border="false" style="width:99.9%">
			<table class="form-table">
				<tr>
					<td class="td-text titleTd"><label>1.下派医生总人数：</label></td>
					<td class="td-content">
						<input name="XPYSZRS" class="form-control" 
						quick-config="label:'下派医生总人数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text titleTd"><label>2.下派医生总天数：</label></td>
					<td class="td-content">
						<input name="XPYSZTS" class="form-control" 
						quick-config="label:'下派医生总天数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>3.下派医生门诊总人次：</label></td>
					<td class="td-content">
						<input name="XPYSMZZRC" class="form-control" 
						quick-config="label:'下派医生门诊总人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>4.下派医生手术总人次：</label></td>
					<td class="td-content">
						<input name="XPYSSSZRC" class="form-control" 
						quick-config="label:'下派医生手术总人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>5.下派医生查房总次数：</label></td>
					<td class="td-content">
						<input name="XPYSCFZCS" class="form-control" 
						quick-config="label:'下派医生查房总次数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>6.接收进修人数：</label></td>
					<td class="td-content">
						<input name="JSJXRS" class="form-control" 
						quick-config="label:'接收进修人数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>7.举办讲座次数：</label></td>
					<td class="td-content">
						<input name="JBJZCS" class="form-control" 
						quick-config="label:'举办讲座次数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>8.培训人次：</label></td>
					<td class="td-content">
						<input name="PXRC" class="form-control" 
						quick-config="label:'培训人次', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
				<tr>
					<td class="td-text"><label>9.联合病房数：</label></td>
					<td class="td-content">
						<input name="LHBFS" class="form-control" 
						quick-config="label:'联合病房数', validateProxy:'notNull length num', length: '10'"/>
					</td>
					<td class="td-text"><label>10.病区床位数：</label></td>
					<td class="td-content">
						<input name="BQCWS" class="form-control" 
						quick-config="label:'病区床位数', validateProxy:'notNull length num', length: '10'"/>
					</td>
				</tr>
			</table>
	
		</div>
	</div>
</form>
	<div region="south" id="south" style="height:45px;line-height:40px;text-align:center;border:0;border-top:1px solid #ddd">
	</div>
</body>
<script type="text/html" id="btnBox">
	<button id="btnTj" class="btn btn-info" type="button">提交</button>
</script>
</html>
